home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / IFF / IFF_Forms / ANIM.brush.doc < prev    next >
Encoding:
Text File  |  1993-03-01  |  7.0 KB  |  341 lines

  1. ANIM brush format
  2.  
  3.               Dpaint Anim Brush IFF Format
  4.  
  5.     From a description by the author of DPaint,
  6.  
  7.                       Dan Silva
  8.                     Electronic Arts
  9.  
  10.  
  11.  
  12. The "Anim Brushes" of DPaint III are saved on disk in the IFF "ANIM" 
  13. format.  Basically, an ANIM Form consists of an initial ILBM 
  14. which is the first frame of the animation, and any number of 
  15. subsequent "ILBM"S (which aren't really ILBM's) each of which 
  16. contains an ANHD animation header chunk and a DLTA chunk  
  17. comprised of the encoded difference between a frame and a previous one.
  18.  
  19.  
  20.  
  21. To use ANIM terminology (for a description of the ANIM format, 
  22. see the IFF Anim Spec, by Gary Bonham). Anim Brushes use a "type 
  23. 5" encoding, which is a vertical, byte-oriented delta encoding 
  24. (based on Jim Kent's RIFF).  The deltas have an interleave of 1, 
  25. meaning deltas are computed between adjacent frames, rather than 
  26. between frames 2 apart, which is the usual ANIM custom for the 
  27. purpose of fast hardware page-flipping.  Also, the deltas use 
  28. Exclusive Or to allow reversable play.
  29.  
  30.  
  31.  
  32. However, to my knowledge, all the existing Anim players in the Amiga
  33. world will only play type 5 "Anim"s which have an interleave of 0 (i.e. 2)
  34. and which use a Store operation rather than Exclusive Or, so no existing
  35. programs will read Anim Brushes anyway.  The job of modifying existing 
  36. Anim readers to read Anim Brushes should be simplified, however.
  37.  
  38.  
  39. Here is an outline of the structure of the IFF Form output by 
  40. DPaint III as an "Anim Brush". The IFF Reader should of course be 
  41. flexible enough to tolerate variation in what chunks actually 
  42. appear in the initial ILBM.
  43.  
  44.  
  45.  
  46.                   FORM ANIM
  47.  
  48.  
  49.  
  50.                       . FORM ILBM         first frame
  51.  
  52.                       . . BMHD        
  53.  
  54.                       . . CMAP
  55.  
  56.                       . . DPPS
  57.  
  58.                       . . GRAB
  59.  
  60.                       . . CRNG
  61.  
  62.                       . . CRNG
  63.  
  64.                       . . CRNG
  65.  
  66.                       . . CRNG
  67.  
  68.                       . . CRNG
  69.  
  70.                       . . CRNG
  71.  
  72.                       . . DPAN     my own little chunk.
  73.  
  74.                       . . CAMG
  75.  
  76.                       . . BODY
  77.  
  78.  
  79.  
  80.                       . FORM ILBM         frame 2
  81.  
  82.                       . . ANHD                animation header chunk
  83.  
  84.                       . . DLTA                delta mode data
  85.  
  86.  
  87.  
  88.                       . FORM ILBM         frame 3
  89.  
  90.                       . . ANHD                animation header chunk
  91.  
  92.                       . . DLTA                delta mode data
  93.  
  94.  
  95.  
  96.                       . FORM ILBM         frame 4
  97.  
  98.                       . . ANHD                animation header chunk
  99.  
  100.                       . . DLTA                delta mode data
  101.  
  102.  
  103.  
  104.        ...
  105.  
  106.  
  107.  
  108.                    . FORM ILBM         frame N
  109.  
  110.                       . . ANHD                animation header chunk
  111.  
  112.                       . . DLTA                delta mode data
  113.  
  114.  
  115.  
  116.  
  117.  
  118. --- Here is the format of the DPAN chunk:
  119.  
  120.  
  121.  
  122. typedef struct {
  123.  
  124.  UWORD version;   /* current version=4 */
  125.  
  126.  UWORD nframes;   /* number of frames in the animation.*/
  127.  
  128.  ULONG flags;   /* Not used */
  129.  
  130.  } DPAnimChunk;
  131.  
  132.  
  133.  
  134.   The version number was necessary during development. At present
  135. all I look at is "nframes".
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143. --- Here is the ANHD chunk format:
  144.  
  145.  
  146.  
  147.  
  148.  
  149. typedef struct {
  150.  
  151.  UBYTE operation;  /* =0  set directly
  152.  
  153.        =1  XOR ILBM mode,
  154.  
  155.        =2 Long Delta mode,
  156.  
  157.        =3 Short Delta mode
  158.  
  159.        =4 Generalize short/long Delta mode,
  160.  
  161.        =5 Byte Vertical Delta (riff)
  162.  
  163.        =74 (Eric Grahams compression mode)
  164.  
  165.    */
  166.  
  167.  UBYTE mask;      /* XOR ILBM only: plane mask where data is*/
  168.  
  169.  UWORD w,h;  
  170.  
  171.  WORD x,y;
  172.  
  173.  ULONG abstime;
  174.  
  175.  ULONG reltime;
  176.  
  177.  UBYTE interleave; /* 0 defaults to 2 */
  178.  
  179.  UBYTE pad0;   /* not used */
  180.  
  181.  ULONG bits;   /* meaning of bits:
  182.  
  183.      bit#    =0         =1
  184.  
  185.     0  short data      long data
  186.  
  187.     1  store         XOR
  188.  
  189.     2  separate info       one info for
  190.  
  191.       for each plane     for all planes
  192.  
  193.     3  not RLC    RLC (run length encoded)
  194.  
  195.     4  horizontal   vertical
  196.  
  197.     5  short info offsets long info offsets
  198.  
  199.    -------------------------*/
  200.  
  201.  UBYTE pad[16];
  202.  
  203.  } AnimHdr;
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211. for Anim Brushes, I set:
  212.  
  213.  
  214.  
  215.  animHdr.operation = 5;  /* RIFF encoding */
  216.  
  217.  animHdr.interleave = 1;
  218.  
  219.  animHdr.w = curAnimBr.bmob.pict.box.w; 
  220.  
  221.  animHdr.h = curAnimBr.bmob.pict.box.h; 
  222.  
  223.  animHdr.reltime = 1;
  224.  
  225.  animHdr.abstime = 0;
  226.  
  227.  animHdr.bits = 4; /* indicating XOR */
  228.  
  229.  
  230.  
  231.  
  232.  
  233. -- everything else is set to 0.
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241. NOTE: the "bits" field was actually intended ( by the original 
  242. creator of the ANIM format, Gary Bonham of SPARTA, Inc.) for use 
  243. with only with compression method 4. I am using bit 2 of the bits 
  244. field to indicate the Exclusive OR operation in the context of 
  245. method 5, which seems like a reasonable generalization. 
  246.  
  247.  
  248.  
  249.  
  250.  
  251. For an Anim Brush with 10 frames, there will be an initial frame 
  252. followed by 10 Delta's (i.e ILBMS containing ANHD and DLTA 
  253. chunks).  Applying the first Delta to the initial frame generates 
  254. the second frame, applying the second Delta to the second frame 
  255. generates the third frame, etc.  Applying the last Delta thus 
  256. brings back the first frame.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262. The DLTA chunk begins with 16 LONG plane offets, of which DPaint 
  263. only uses the first 6 (at most).  These plane offsets are either 
  264. the offset (in bytes ) from the beginning of the DLTA chunk to 
  265. the data for the corresponding plane, or Zero, if there was no 
  266. change in that plane.  Thus the first plane offset is either 0 or 
  267. 64.
  268.  
  269.  
  270.  
  271. (The following description of the method is based on Gary Bonham's 
  272. rewording of Jim Kent's RIFF documentation.)
  273.  
  274.  
  275.  
  276.  
  277.  
  278.   Compression/decompression is performed on a plane-by-plane 
  279.   basis.  
  280.  
  281.  
  282.  
  283.   Each byte-column of the bitplane is compressed separately.  A 
  284.   320x200 bitplane would have 40 columns of 200 bytes each.  In 
  285.   general, the bitplanes are always an even number of bytes wide, 
  286.   so for instance a 17x20 bitplane would have 4 columns of 20 
  287.   bytes each.
  288.  
  289.  
  290.  
  291.   Each column starts with an op-count followed by a number of 
  292.   ops.  If the op-count is zero, that's ok, it just means there's 
  293.   no change in this column from the last frame.  The ops are of 
  294.   three kinds, and followed by a varying amount of data depending 
  295.   on which kind:
  296.  
  297.  
  298.  
  299.      1. SKIP - this is a byte with the hi bit clear that   says 
  300.         how many rows to move the "dest" pointer forward, ie to 
  301.         skip. It is non-zero.
  302.  
  303.  
  304.  
  305.      2. DUMP - this is a byte with the hi bit set.  The hi bit is 
  306.         masked off and the remainder is a count of the number of 
  307.         bytes of data to XOR directly.  It is followed by the 
  308.         bytes to copy.
  309.  
  310.  
  311.  
  312.      3. RUN - this is a 0 byte followed by a count byte, followed 
  313.         by a byte value to repeat "count" times, XOR'ing it into 
  314.         the destination.
  315.  
  316.  
  317.  
  318.  
  319.  
  320.   Bear in mind that the data is compressed vertically rather than 
  321.   horizontally, so to get to the next byte in the destination  you 
  322.   add the number of bytes per row instead of one.
  323.  
  324.  
  325.  
  326. The Format of DLTA chunks is as described in section 2.2.2 
  327. of the Anim Spec. The encoding for type 5 is described in section 
  328. 2.2.3 of the Anim Spec.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.